from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field
from typing import Type,Any

class CaculatorInput(BaseModel):
    a: int = Field(description="第一个参数")
    b: int = Field(description="第二个参数")

class MultiplyTool(BaseTool):
    """乘法工具"""
    name:str = "multiply_tools"
    description:str = "将传递的两个参数相乘"
    args_schema:Type[BaseModel] = CaculatorInput

    def _run(self,a:int,b:int)->Any:
        return a*b

calculator =MultiplyTool()
print("函数名称",calculator.name)
print("函数描述",calculator.description)
print("函数参数",calculator.args)
print("是否直接返回",calculator.return_direct)
print(calculator.invoke({"a":7,"b":8}))
